﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.GarageLogic
{
    public class VehicleTypes
    {
        public enum eVehicleType
        {
            Internal_Combustion_Bike = 1,
            Electric_Bike,
            Internal_Combustion_Car,
            Electric_Car,
            Internal_Combustion_Bus
        }

        public static String[] GetVehicleTypeHandleByTheGarage()
        {
            String[] vehicleTypes = Enum.GetNames(typeof(eVehicleType));
            List<String> returnValue = new List<String>();
            Char[] typeInChar = null;

            for (int j = 0; j < vehicleTypes.Length; j++)
            {
                typeInChar = vehicleTypes[j].ToCharArray();
                for (int i = 0; i < vehicleTypes[j].Length; i++)
                {
                    if (typeInChar[i] == '_')
                    {
                        typeInChar[i] = ' ';
                    }
                }
                returnValue.Add(new String(typeInChar));
            }

            return returnValue.ToArray();
        }

        public static Vehicle CreateNewVehicle(eVehicleType i_VehicleType)
        {
            Vehicle returnValue = null;

            switch (i_VehicleType)
            {
                case eVehicleType.Electric_Bike:
                    returnValue = new ElectricBike();
                    break;

                case eVehicleType.Electric_Car:
                    returnValue = new ElectricCar();
                    break;

                case eVehicleType.Internal_Combustion_Bike:
                    returnValue = new InternalCombustionBike();
                    break;

                case eVehicleType.Internal_Combustion_Bus:
                    returnValue = new InternalCombustionBus();
                    break;

                case eVehicleType.Internal_Combustion_Car:
                    returnValue = new InternalCombustionCar();
                    break;
                default:
                    returnValue = null;
                    break;
            }

            return returnValue;
        }
    }
}
